package cn.tedu.csmall.product.mapper;

import cn.tedu.csmall.product.pojo.entity.Album;
import cn.tedu.csmall.product.pojo.vo.AlbumListitemVO;
import cn.tedu.csmall.product.pojo.vo.AlbumStandardVO;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;
import java.util.List;

@SpringBootTest
public class AlbumMapperTets {
   @Autowired
   AlbumMapper mapper;
   @Test
    void testInsert(){
       Album album=new Album();
       album.setName("某电视的相册");
       album.setDescription("某电视机的相册的描述");
       album.setSort(63);
       int rows=mapper.insert(album);
       System.out.println("rows = "+rows);
   }
   @Test
   void testInserts(){
      List<Album> list=new ArrayList<>();
      for (int i = 0; i <5 ; i++) {
         Album album=new Album();
         album.setName("测试相册"+i);
         album.setDescription("测试相册的简介"+i);
         album.setSort(50+i);
         list.add(album);
      }
      int row=mapper.insertBatch(list);
   }
   @Test
   void testDeleteById(){
      Long id=1L;
      int row= mapper.delete(id);
      System.out.println("row = "+row);
   }
   @Test
   void testDeleteByIds(){
      Long [] ids={1L,2L,3L,4L,5L,6L};
      int rows=mapper.deletes(ids);
   }
   @Test
   void testUpdate(){
      Album album=new Album();
         album.setId(6L);
         album.setName("测试相册logo");
         album.setDescription("测试相册logo简介");
         album.setSort(55);
         int row=mapper.update(album);
         System.out.println(row);
   }
   @Test
   void testCount(){
      int count= mapper.count();
      System.out.println("count = "+count);
   }
   @Test
   void a(){
      Long a=6L;
      AlbumStandardVO album = mapper.getAlbum(a);
      System.out.println(album);
   }
   @Test
   void testList(){
      List<AlbumListitemVO> list = mapper.listAlbum();
      for (AlbumListitemVO album:list) {
         System.out.println(list);
      }
   }

}
